<template>
  <div :id="id" :class="className" :style="{height:height,width:width}">
</div>
</template>

<script>
import echarts from 'echarts'
import resize from '@/utils/resizeMixins'

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    id: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '200px'
    },
    height: {
      type: String,
      default: '200px'
    },
    option: {
    }
  },
  data() {
    return {
      chartNine: null
    }
  },
  mounted() {
    console.info(123+this.option)
    this.initChart()
  },
  beforeDestroy() {
    if (!this.chartNine) {
      return
    }
    this.chartNine.dispose()
    this.chartNine = null
  },
  methods: {
    initChart() {
      this.chartNine = echarts.init(document.getElementById(this.id))
      this.chartNine.setOption(this.option)
    }
  }
}
</script>
